package top.psjj.ssm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.psjj.ssm.entity.User;
import top.psjj.ssm.service.UserService;

@Controller
@RequestMapping("/api/user/")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/save")
    @ResponseBody
    public String save(User user){
        boolean b = userService.insertUser(user);
        if(b){
            return "ok";
        }else {
            return "no";
        }
    }

    @GetMapping("/hello")
    public String hello(Model model){
        model.addAttribute("name","张三");
        return "demo1";
    }
}
